<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" type="text/css" href="../../HTMLTurbo.css">
<link rel="stylesheet" type="text/css" href="../style/demo.css">

<script charset="utf-8" src="../../jquery/1.12.4/jquery.min.js"></script>
<script charset="utf-8" src="../../HTMLTurbo.php"></script>
</head>

<body>
<div class="ht">
值：
<input name="value" id="value" type="text" value="" list="optionList"/>
<datalist id="optionList">
	<option>男</option>
	<option>女</option>
</datalist>
<script>
$("input[list]").bind("focus",function(event){
	console.log("focus");
	var target=event.currentTarget
	var sourceValue=$(target).val();
	
	$(target).val("");
	if(sourceValue!="" && typeof sourceValue!="undefined"){
		$(target).attr("data-sourceValue",sourceValue);
	}
})
$("input[list]").bind("blur",function(event){
	console.log("blur");
	var target=event.currentTarget;
	
	var value=$(target).val();
	var sourceValue=$(target).attr("data-sourceValue");
	
	console.log(1)
	console.log(value);
	console.log(sourceValue);
	console.log(2)
	if(value=="" || typeof value=="undefined"){
		console.log(3);
		if(sourceValue!="" && typeof sourceValue!="undefined"){
			console.log(4);
			$(target).val(sourceValue);
		}
	}
})
</script>
</div>
</body>
</html>
